#include <iostream>
#include "msg.pb.h"

int main(int argc, char**argv)
{
	test::msg obj;
	obj.set_id(2);
	obj.set_str("hello world");

	auto length = obj.ByteSize();
	auto size = obj.GetCachedSize();
	std::cout<<length<<" len - size "<<size<<std::endl;

	std::string data;
	obj.SerializeToString(&data);
	std::cout<<data.c_str()<<std::endl;

	test::msg nobj;
	nobj.ParseFromString(data);
	std::cout<<nobj.id()<<nobj.str()<<nobj.opt()<<std::endl;

/*	byte array Serialize/Parse
	char* buf = new char[length];
	obj.SerializeToArray(buf, length);
	std::cout<<buf<<std::endl;

	test::msg nobj;
	nobj.ParseFromArray(buf, length);
	std::cout<<nobj.id()<<nobj.str()<<nobj.opt()<<std::endl;
*/
	return 0;
}

